<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@ taglib uri="http://myfaces.apache.org/tomahawk" prefix="t"%>
<%@ taglib uri="http://richfaces.org/a4j" prefix="a4j"%>
<%@ taglib uri="http://richfaces.org/rich" prefix="rich"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-tiles"
	prefix="tiles"%>

<rich:panel header="#{messages['voucher.mgmt.label']}">
	<h:panelGrid>
		<h:outputText value="#{errorBean.errorMessage}" styleClass="error"></h:outputText>
	</h:panelGrid>
	
	<h:panelGrid width="100%" rendered="#{!voucherMgmtBean.lookupForm}">
		<h:panelGroup>
		    <h:outputText value="#{messages['voucher.assignment.label']}" styleClass="sub_header" />
			<h:outputText value="*" styleClass="standardText_Mandatory" />
			<h:outputText value="#{messages['instruction']}" styleClass="standardText_Instruction" />
		</h:panelGroup>
	</h:panelGrid>
	
	<t:panelGrid rendered="#{!voucherMgmtBean.lookupForm}" columns="2" columnClasses="standardTable_ColumnLeft_20,standardTable_ColumnLeft_80" width="100%">
		<h:outputText></h:outputText>
		<t:message for="assignTo" styleClass="error"></t:message>
		
		<h:panelGroup>
			<h:outputText value="*" styleClass="standardText_Mandatory" />
			<h:outputLabel for="assignTo" value="#{messages['voucher.assign.to.label']}" styleClass="standardText_Label" />
		</h:panelGroup>
		<h:panelGroup>
		    <t:selectOneRadio id="assignTo" layout="lineDirection" required="true" styleClass="standardText" value="#{voucherMgmtBean.assignType}" >
		    	<f:selectItems  value="#{voucherMgmtBean.selectAssignTypeList}" />
		    	<a4j:support ajaxSingle="true" event="onclick" reRender="assignTo,assignToLabel,assignToLabelDesc"></a4j:support>
		    </t:selectOneRadio> 
		</h:panelGroup>	
		
		<h:outputText></h:outputText>
		<t:message for="assignToLabel" styleClass="error"></t:message>
		
		<h:panelGroup>
			<h:outputText value="*" styleClass="standardText_Mandatory" />
			<h:outputLabel id="assignToLabelDesc" for="assignToLabel" value="#{voucherMgmtBean.assignToLabel}" styleClass="standardText_Label" />
		</h:panelGroup>
		<h:panelGroup>
			<t:selectOneMenu id="assignToLabel" styleClass="standardText" value="#{voucherMgmtBean.assignToId}" required="true">
				<f:selectItem itemLabel="#{messages['please.select']}" itemValue="" />
				<f:selectItems value="#{voucherMgmtBean.selectAssignToList}" />
			</t:selectOneMenu>
		</h:panelGroup>	
		
		<h:outputText></h:outputText>
		<t:message for="startVoucher" styleClass="error"></t:message>
		<h:panelGroup>
			<h:outputText value="*" styleClass="standardText_Mandatory" />
			<h:outputLabel for="startVoucher" value="#{messages['voucher.start.label']}" styleClass="standardText_Label" />
		</h:panelGroup>
		<h:panelGroup>
		    <h:inputText size="20" maxlength="20" readonly="true" value="#{voucherMgmtBean.startVoucher.voucherNo}" required="true"></h:inputText>
			<h:commandButton value="#{messages['search']}" styleClass="button" action="null" actionListener="#{voucherMgmtBean.lookupFormStartVoucherAssignActionEvent}" immediate="true">
			</h:commandButton>
		    <h:inputHidden required="true" id="startVoucher" value="#{voucherMgmtBean.startVoucher.voucherId}"></h:inputHidden> 
		   
		</h:panelGroup>
		
		<h:outputText value="#{messages['voucher.product.label']}" styleClass="standardText_Label" />
		<h:outputText id="StartVProduct" value="#{voucherMgmtBean.startVProductCode}" styleClass="standardText" />
		
		<h:outputText value="#{messages['voucher.no.of.person.label']}" styleClass="standardText_Label" />
		<h:outputText id="startVnoOfPerson"  value="#{voucherMgmtBean.startVoucher.noOfPerson}" styleClass="standardText" />
		
		<h:outputText value="#{messages['voucher.no.of.nights.label']}" styleClass="standardText_Label" />
		<h:outputText id="startVNoOfNights" value="#{voucherMgmtBean.startVoucher.noOfNights}" styleClass="standardText" />
		
		<h:outputText value="#{messages['effective.date.label']}" styleClass="standardText_Label" />
		<h:outputText id="startVEffectiveDate" value="#{voucherMgmtBean.startVoucher.effectiveDate}" styleClass="standardText" >
			<f:convertDateTime pattern="dd/MM/yyyy" timeZone="Asia/Kuala_Lumpur"/>
		</h:outputText>
		
		<h:outputText value="#{messages['expiry.date.label']}" styleClass="standardText_Label" />
		<h:outputText id="startVExpiryDate" value="#{voucherMgmtBean.startVoucher.expiryDate}" styleClass="standardText" >
			<f:convertDateTime pattern="dd/MM/yyyy" timeZone="Asia/Kuala_Lumpur"/>
		</h:outputText>
		
		<h:outputText></h:outputText>
		<t:message for="lastVoucher" styleClass="error"></t:message>
		<h:panelGroup>
			<h:outputText value="*" styleClass="standardText_Mandatory" />
			<h:outputLabel for="lastVoucher" value="#{messages['voucher.last.label']}" styleClass="standardText_Label" />
		</h:panelGroup>
		<h:panelGroup>
		    <h:inputText size="20" maxlength="20" readonly="true" value="#{voucherMgmtBean.lastVoucher.voucherNo}" required="true"></h:inputText>
			<h:commandButton value="#{messages['search']}" styleClass="button" action="null" actionListener="#{voucherMgmtBean.lookupFormLastVoucherAssignActionEvent}" immediate="true">
			</h:commandButton>
		    <h:inputHidden  required="true" id="lastVoucher" value="#{voucherMgmtBean.lastVoucher.voucherId}"></h:inputHidden>
		</h:panelGroup>
		
		<h:outputText value="#{messages['voucher.product.label']}" styleClass="standardText_Label" />
		<h:outputText id="lastVProductCode" value="#{voucherMgmtBean.lastVProductCode}" styleClass="standardText" />
		
		<h:outputText value="#{messages['voucher.no.of.person.label']}" styleClass="standardText_Label" />
		<h:outputText id="lastVNoOfPerson" value="#{voucherMgmtBean.lastVoucher.noOfPerson}" styleClass="standardText" />
		
		<h:outputText value="#{messages['voucher.no.of.nights.label']}" styleClass="standardText_Label" />
		<h:outputText id="lastVNoOfNights" value="#{voucherMgmtBean.lastVoucher.noOfNights}" styleClass="standardText" />
		
		<h:outputText value="#{messages['effective.date.label']}" styleClass="standardText_Label" />
		<h:outputText id="lastVEffectiveDate" value="#{voucherMgmtBean.lastVoucher.effectiveDate}" styleClass="standardText" >
			<f:convertDateTime pattern="dd/MM/yyyy" timeZone="Asia/Kuala_Lumpur"/>
		</h:outputText>
		
		<h:outputText value="#{messages['expiry.date.label']}" styleClass="standardText_Label" />
		<h:outputText id="lastVExpiryDate" value="#{voucherMgmtBean.lastVoucher.expiryDate}" styleClass="standardText" >
			<f:convertDateTime pattern="dd/MM/yyyy" timeZone="Asia/Kuala_Lumpur"/>
		</h:outputText>
	</t:panelGrid>
	
	<rich:spacer rendered="#{!voucherMgmtBean.lookupForm}" height="10"></rich:spacer>
	
	<t:panelGrid columns="2" rendered="#{!voucherMgmtBean.lookupForm}" columnClasses="standardTable_ColumnLeft_20,standardTable_ColumnLeft_80" width="100%">
		<h:outputText></h:outputText>
		<h:commandButton value="#{messages['assign']}" styleClass="button" action="#{voucherMgmtBean.voucherAssignmentAction}" actionListener="#{voucherMgmtBean.voucherAssignmentActionEvent}"></h:commandButton>
	</t:panelGrid>
	
	<h:panelGrid width="100%" rendered="#{voucherMgmtBean.lookupForm}" columns="1">
		<h:outputText value="#{messages['voucher.lookup.label']}" styleClass="sub_header" />
		
		<rich:dataTable id="data" var="voucher" value="#{voucherMgmtBean.voucherList}" rows="20" width="99%">
			<rich:column style="text-align:center;width:10%;">
					<f:facet name="header">
						<h:outputText value="#{messages['voucher.no.column']}"></h:outputText>
					</f:facet>
				
					<h:commandLink action="#{voucherMgmtBean.backVoucherAssignmentAction}" actionListener="#{voucherMgmtBean.lookupFormVoucherAssignSelectedActionEvent}">
						<h:outputText value="#{voucher.voucherNo}"></h:outputText>
						<a4j:support ajaxSingle="true" event="onclick" reRender="startVoucher,lastVoucher"></a4j:support>
					</h:commandLink>
					<f:param id="voucherId" value="#{voucher.voucherId}" />
			</rich:column>
			
			<rich:column style="text-align:center;width:10%;">
					<f:facet name="header">
						<h:outputText value="#{messages['voucher.issue.date.column']}"></h:outputText>
					</f:facet>
					<h:outputText value="#{voucher.createdDate}">
						<f:convertDateTime pattern="dd/MM/yyyy" timeZone="Asia/Kuala_Lumpur"/>
					</h:outputText>
			</rich:column>
			
			<rich:column style="text-align:center;width:10%;">
					<f:facet name="header">
						<h:outputText value="#{messages['voucher.no.of.nights.column']}"></h:outputText>
					</f:facet>
					<h:outputText value="#{voucher.noOfNights}">						
					</h:outputText>
			</rich:column>		
			
			<rich:column style="text-align:center;width:10%;">
					<f:facet name="header">
						<h:outputText value="#{messages['voucher.no.of.person.column']}"></h:outputText>
					</f:facet>
					<h:outputText value="#{voucher.noOfPerson}">						
					</h:outputText>
			</rich:column>
		</rich:dataTable>
		
		<rich:spacer height="10"></rich:spacer>
					
		<rich:datascroller align="left"  for="data" maxPages="20" />
			
		<h:commandButton value="#{messages['back']}" styleClass="button" action="null" 
			actionListener="#{voucherMgmtBean.lookupFormVoucherAssignCloseActionEvent}" immediate="true">
		</h:commandButton>
	</h:panelGrid>
</rich:panel>	